class Solution {
public:
    int totalMoney(int n) {
        //每周存钱数=28+(周数-1)*7
        int week=n/7;
        int reminday=n-week*7; //剩余天数
        int remind=reminday*(reminday+1)/2+week*reminday;
        return week*28+week*(week-1)/2*7+remind;
    }
};